const webpack = require('webpack');
const htmlWebpackPlugin = require('html-webpack-plugin');
const genPath = require('./build/path.js');
const fs = require('fs');
const path = require('path');

module.exports = {
    devtool:'cheap-module-source-map',
    entry:[
        genPath.appIndexJs
    ],
    output:{
        pathinfo:true,
        path:path.resolve(process.cwd(),'dist/static/js'),
        filename:'bundle.js',
        chunkFilename:'[name].[chunkhash:8].chunk.js',
        publicPath:genPath.publicPath
    },
    resolve:{
        extensions:['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
        alias:{
            'babel-runtime': path.dirname(
                require.resolve('babel-runtime/package.json')
              ),
        }
    },
    plugins:[
        new htmlWebpackPlugin({
            template:genPath.templatePath
        })
    ],
    module:{
        rules:[
            {
                test: /\.(js|jsx|mjs)$/,
                include:genPath.srcPath,
                loader:'babel-loader',
              
            }
        ]
    }
};